﻿<!DOCTYPE html>
@{
    var isEmbed = Context?.Request?.Query["embed"].ToString() == "1";
    var currentController = ViewContext.RouteData.Values["Controller"]?.ToString();
    var currentAction = ViewContext.RouteData.Values["Action"]?.ToString();
}
<html lang="zh-CN">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"] - MES制造执行系统</title>
    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
    <link rel="stylesheet" href="~/MES.MVC.styles.css" asp-append-version="true" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" />
    <style>
        /* Embedded mode: remove outer paddings and backgrounds */
        body.embedded .container { max-width: 100%; padding-left: 0; padding-right: 0; }
        body.embedded main { padding-bottom: 0; }
        
        /* MES系统主题样式 */
        :root {
            --primary-color: #1e88e5;
            --secondary-color: #ff6f00;
            --success-color: #43a047;
            --warning-color: #ff9800;
            --danger-color: #f44336;
            --dark-color: #263238;
            --light-color: #f5f5f5;
            --sidebar-width: 280px;
            --header-height: 60px;
        }

        body {
            font-family: 'Microsoft YaHei', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f8f9fa;
            margin: 0;
            padding: 0;
        }

        /* 顶部导航栏 */
        .top-navbar {
            background: linear-gradient(135deg, var(--primary-color), #1565c0);
            height: var(--header-height);
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            z-index: 1030;
            display: flex;
            align-items: center;
            padding: 0 20px;
        }

        .navbar-brand {
            color: white !important;
            font-size: 24px;
            font-weight: bold;
            text-decoration: none;
        }

        .navbar-brand i {
            margin-right: 10px;
            color: var(--secondary-color);
        }

        .user-info {
            color: white;
            margin-left: auto;
            display: flex;
            align-items: center;
        }

        .user-avatar {
            width: 35px;
            height: 35px;
            border-radius: 50%;
            background-color: var(--secondary-color);
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 10px;
            color: white;
            font-weight: bold;
        }

        /* 侧边栏 */
        .sidebar {
            position: fixed;
            left: 0;
            top: var(--header-height);
            width: var(--sidebar-width);
            height: calc(100vh - var(--header-height));
            background: white;
            box-shadow: 2px 0 10px rgba(0,0,0,0.1);
            overflow-y: auto;
            z-index: 1020;
            transition: all 0.3s ease;
        }

        .sidebar-menu {
            padding: 0;
            list-style: none;
            margin: 0;
        }

        .sidebar-menu li {
            margin: 0;
        }

        .sidebar-menu a {
            display: flex;
            align-items: center;
            padding: 15px 20px;
            color: #666;
            text-decoration: none;
            border-left: 3px solid transparent;
            transition: all 0.3s ease;
        }

        .sidebar-menu a:hover {
            background-color: #f8f9fa;
            color: var(--primary-color);
            border-left-color: var(--primary-color);
        }

        .sidebar-menu a.active {
            background-color: #e3f2fd;
            color: var(--primary-color);
            border-left-color: var(--primary-color);
            font-weight: 600;
        }

        .sidebar-menu i {
            width: 20px;
            margin-right: 15px;
            text-align: center;
        }

        .sidebar-menu .menu-text {
            transition: opacity 0.3s ease;
        }

        /* 子菜单样式 */
        .sidebar-menu ul {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        .sidebar-menu ul li a {
            padding: 12px 20px 12px 40px;
            font-size: 0.9rem;
            border-left: 2px solid transparent;
        }

        .sidebar-menu ul li a:hover {
            background-color: #f0f8ff;
            border-left-color: var(--primary-color);
        }

        .sidebar-menu ul li a.active {
            background-color: #e3f2fd;
            border-left-color: var(--primary-color);
            color: var(--primary-color);
            font-weight: 500;
        }

        /* 主内容区域 */
        .main-content {
            margin-left: var(--sidebar-width);
            margin-top: var(--header-height);
            padding: 20px;
            min-height: calc(100vh - var(--header-height));
            transition: margin-left 0.3s ease;
        }

        /* 面包屑导航 */
        .breadcrumb-nav {
            background: white;
            padding: 15px 20px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
            margin-bottom: 20px;
        }

        .breadcrumb-nav .breadcrumb {
            margin: 0;
            background: none;
            padding: 0;
        }

        .breadcrumb-item + .breadcrumb-item::before {
            content: ">";
            color: #999;
        }

        /* 卡片样式 */
        .content-card {
            background: white;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            padding: 20px;
            margin-bottom: 20px;
        }

        /* 状态指示器 */
        .status-indicator {
            display: inline-block;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            margin-right: 8px;
        }

        .status-online { background-color: var(--success-color); }
        .status-offline { background-color: var(--danger-color); }
        .status-warning { background-color: var(--warning-color); }
    </style>
</head>
<body class="@(isEmbed ? "embedded" : string.Empty)">
    @if (!isEmbed)
    {
        <!-- 顶部导航栏 -->
        <nav class="top-navbar">
            <a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">
                <i class="fas fa-industry"></i>
                MES制造执行系统
            </a>
            
            <div class="user-info">
                <div class="user-avatar">
                    <i class="fas fa-user"></i>
                </div>
                <span>管理员</span>
            </div>
        </nav>

        <!-- 侧边栏导航 -->
        <nav class="sidebar" id="sidebar">
            <ul class="sidebar-menu">
                <!-- 工序管理 -->
                <li>
                    <a href="#" class="@(currentController == "Process" ? "active" : "")">
                        <i class="fas fa-cogs"></i>
                        <span class="menu-text">工序管理</span>
                    </a>
                    <ul class="sidebar-menu" style="padding-left: 20px;">
                        <li>
                            <a href="/Process/ProcessType" class="@(currentController == "Process" && currentAction == "ProcessType" ? "active" : "")">
                                <i class="fas fa-tags"></i>
                                <span class="menu-text">工序分类</span>
                            </a>
                        </li>
                        <li>
                            <a href="/Process/Process" class="@(currentController == "Process" && currentAction == "Process" ? "active" : "")">
                                <i class="fas fa-list"></i>
                                <span class="menu-text">工序管理</span>
                            </a>
                        </li>
                        <li>
                            <a href="/Process/Technology" class="@(currentController == "Process" && currentAction == "Technology" ? "active" : "")">
                                <i class="fas fa-project-diagram"></i>
                                <span class="menu-text">工艺管理</span>
                            </a>
                        </li>
                    </ul>
                </li>
            </ul>
        </nav>

        <!-- 主内容区域 -->
        <div class="main-content" id="mainContent">
            <!-- 页面内容 -->
            <div class="content-card">
                @RenderBody()
            </div>
        </div>
    }
    else
    {
        <!-- 嵌入式模式 -->
        <div class="container-fluid">
            <main role="main" class="pb-3">
                @RenderBody()
            </main>
        </div>
    }

    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script src="~/js/site.js" asp-append-version="true" />
    
    <script>
        // 页面初始化脚本
        document.addEventListener('DOMContentLoaded', function() {
            // 页面加载完成后的初始化逻辑
            console.log('MES系统已加载完成');
        });
    </script>
    
    @await RenderSectionAsync("Scripts", required: false)
</body>
</html>
